#!/usr/bin/env python
#RFNoC ModTool
""" OOT modules for RFNoC """

from __future__ import print_function
import sys
from ettus.rfnoc_modtool import *

def main():
    """ Initialization. Parse command, choose class and run. """
    cmd_dict = get_class_dict(globals().values())
    command = get_command_from_argv(cmd_dict.keys())
    if command is None:
        print('Usage:' + Templates['usage'])
        exit(2)
    modtool = cmd_dict[command]()
    try:
        (args, positional) = modtool.parser.parse_known_args()
        modtool.setup(args, positional)
        modtool.run()

    except ModToolException as err:
        print(err, file=sys.stderr)
        exit(1)

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass
